package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

public class CollectionDemo {
    public static void main(String[] args) {
        Collection c1 = new ArrayList();
        c1.add(new Point(1,2));
        c1.add(new Point(1,2));
        c1.add(new Point(1,2));
        c1.add(new Point(1,2));
        System.out.println(c1);
        System.out.println();
        Collection c2 = new HashSet();
        c2.add("ccc");
        c2.add("bbb");
        c2.add("aaa");
        c2.add("ccc");
        c2.add("aaa");
        System.out.println(c2);
        System.out.println(c2.size());

        Point p = new Point(1, 2);
        boolean contains = c1.contains(p);
        System.out.println("是否包含："+contains);
        c1.remove(p);
        System.out.println(c1);

        Collection cc = new ArrayList();
        cc.add(p);
        System.out.println("p:"+p);
        System.out.println("cc:"+cc);

        p.setX(100);
        System.out.println("p:"+p);
        System.out.println("cc:"+cc);

        c2.addAll(c1);
        System.out.println(c2);
        System.out.println(c1);

        c2.retainAll(c1);
        System.out.println(c2);
        System.out.println(c1);
    }
}
